package com.edu.exam.enums.audit;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 审核任务类型枚举
 */
public enum AuditTaskType implements BaseEnum {

    REVIEW("REVIEW", "审核", 1),
    VALIDATE("VALIDATE", "验证", 2),
    APPROVE("APPROVE", "批准", 3),
    SIGN("SIGN", "签名", 4),
    CHECK("CHECK", "检查", 5),
    ASSESS("ASSESS", "评估", 6),

    // 成绩审核相关类型
    GRADE_ENTRY("GRADE_ENTRY", "成绩录入审核", 10),
    GRADE_IMPORT("GRADE_IMPORT", "成绩导入审核", 11),
    GRADE_MODIFY("GRADE_MODIFY", "成绩修改审核", 12),
    GRADE_APPEAL("GRADE_APPEAL", "成绩申诉审核", 13),
    GRADE_CORRECTION("GRADE_CORRECTION", "成绩更正审核", 14),

    // 工作流审核类型
    MANUAL_AUDIT("MANUAL_AUDIT", "人工审核", 20),
    SKIP_AUDIT("SKIP_AUDIT", "跳过审核", 21),

    // 质量审核类型
    QUALITY_REVIEW("QUALITY_REVIEW", "质量审核", 30),
    PROCESS_AUDIT("PROCESS_AUDIT", "流程审核", 31),
    COMPLIANCE_AUDIT("COMPLIANCE_AUDIT", "合规审核", 32),

    // 试卷审核类型
    PAPER_REVIEW("PAPER_REVIEW", "试卷审核", 40),
    QUESTION_AUDIT("QUESTION_AUDIT", "试题审核", 41),
    CONTENT_CHECK("CONTENT_CHECK", "内容检查", 42),

    // 系统审核类型
    SYSTEM_AUDIT("SYSTEM_AUDIT", "系统审核", 50),
    DATA_AUDIT("DATA_AUDIT", "数据审核", 51),
    SECURITY_AUDIT("SECURITY_AUDIT", "安全审核", 52);

    private final String code;
    private final String description;
    private final int order;

    AuditTaskType(String code, String description, int order) {
        this.code = code;
        this.description = description;
        this.order = order;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public int getOrder() {
        return order;
    }

    /**
     * 根据编码查找枚举值
     */
    public static AuditTaskType fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            return REVIEW; // 默认审核类型
        }

        for (AuditTaskType value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return REVIEW;
    }

    /**
     * 根据描述查找枚举值
     */
    public static AuditTaskType fromDescription(String description) {
        if (description == null || description.trim().isEmpty()) {
            return REVIEW; // 默认审核类型
        }

        for (AuditTaskType value : values()) {
            if (value.getDescription().equals(description)) {
                return value;
            }
        }
        return REVIEW;
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}